﻿package core.ui.dialogs
{
    import core.enum.*;
    import core.event.*;
    import core.image.*;
    import core.ui.controls.*;

    public class HalftoneDialog extends BitmapOperationDialogBase
    {
        var f:Filter;
        var b:Slidebar;
        var m:Slidebar;
        var inverse:Checkbox;
        var overlay:Checkbox;

        public function HalftoneDialog(param1:Tuyitu)
        {
            super(param1, "rm_halftone", 240, 220, Action.HalftoneFilter);
            this.f = new Filter();
            this.b = new Slidebar("rm_point_size", 2, 25, 200, 5);
            this.b.addEventListener(SliderEvent.CHANGE, this.Change, false, 1, true);
            this.b.x = 20;
            this.b.y = 35;
            addChild(this.b);
            this.m = new Slidebar("rm_multiplier", 1, 100, 200, 10);
            this.m.addEventListener(SliderEvent.CHANGE, this.Change, false, 1, true);
            this.m.x = 20;
            this.m.y = 80;
            addChild(this.m);
            this.overlay = new Checkbox("rm_add");
            this.overlay.addEventListener(SliderEvent.CHANGE, this.Change, false, 1, true);
            this.overlay.x = 20;
            this.overlay.y = 130;
            this.overlay.Check();
            addChild(this.overlay);
            this.inverse = new Checkbox("rm_inverse");
            this.inverse.addEventListener(SliderEvent.CHANGE, this.Change, false, 1, true);
            this.inverse.x = 20;
            this.inverse.y = 155;
            addChild(this.inverse);
            return;
        }// end function

        override public function Change(... args) : void
        {
            if (!locked)
            {
                bm.copyPixels(bc, bm.rect, bm.rect.topLeft);
                this.f.Halftone(bm, bc, this.b.value * 2, this.m.value / 20, this.overlay.checked, this.inverse.checked, ed.toolbar.GetColor(), selection, offset);
            }
            return;
        }// end function

    }
}
